package com.jms.web.mvc.utils;

import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

public class RequestUtils {

    public static String getRequestBody(HttpServletRequest request) throws IOException {
        StringBuilder body = new StringBuilder();
        ServletInputStream inputStream = request.getInputStream();
        byte[] buffer = new byte[1024];
        int len;
        while ((len = inputStream.read(buffer)) != -1) {
            body.append(new String(buffer, 0, len));
        }
        return body.toString();
    }
}
